﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Web.Configuration;

using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ES_Project.Pages
{
    public partial class WebForm3 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected static void RefreshOpener(Page pPage, int num)
        {
            #region "โชว์ในแต่ละเมนูย่อย"
            System.Text.StringBuilder strBuilder = new System.Text.StringBuilder();
            if (num == 1)
            {
                strBuilder.Append("document.getElementById('row1').style.display = 'block';");
                strBuilder.Append("document.getElementById('row2').style.display = 'none';");
                strBuilder.Append("document.getElementById('row3').style.display = 'none';");
                strBuilder.Append("document.getElementById('row4').style.display = 'none';");

            }
            else if (num == 2)
            {
                strBuilder.Append("document.getElementById('row1').style.display = 'none';");
                strBuilder.Append("document.getElementById('row2').style.display = 'block';");
                strBuilder.Append("document.getElementById('row3').style.display = 'none';");
                strBuilder.Append("document.getElementById('row4').style.display = 'none';");
            }
            else if (num == 3)
            {
                strBuilder.Append("document.getElementById('row1').style.display = 'none';");
                strBuilder.Append("document.getElementById('row2').style.display = 'none';");
                strBuilder.Append("document.getElementById('row3').style.display = 'block';");
                strBuilder.Append("document.getElementById('row4').style.display = 'none';");
            }
            else if (num == 4)
            {
                strBuilder.Append("document.getElementById('row1').style.display = 'none';");
                strBuilder.Append("document.getElementById('row2').style.display = 'none';");
                strBuilder.Append("document.getElementById('row3').style.display = 'none';");
                strBuilder.Append("document.getElementById('row4').style.display = 'block';");
            }

            else if (num == 0)
            {
                strBuilder.Append("document.getElementById('row1').style.display = 'none';");
                strBuilder.Append("document.getElementById('row2').style.display = 'none';");
                strBuilder.Append("document.getElementById('row3').style.display = 'none';");
                strBuilder.Append("document.getElementById('row4').style.display = 'none';");
            }
          
                

            ScriptManager.RegisterStartupScript(pPage, typeof(Page), "RefreshOpener", strBuilder.ToString(), true);
            #endregion
        }
        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            RefreshOpener(Page, Int32.Parse(DropDownList1.SelectedValue));
        }
    }
}